package com.struts2.action;

import java.util.Date;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;

import com.hibernate.HibernateUtil;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.struts2.model.Product_item;
import com.struts2.model.Product_line;
import com.struts2.service.ProductDetailService;
import com.struts2.service.ProductSearchService;

public class ProductDetailAction extends ActionSupport implements ModelDriven<List<Product_item>>{
	private int id;

	private List<Product_item> product_items;
	private List<Product_line> product_lines;

	
	public String execute() {

		ProductSearchService productListService = new ProductSearchService();
		ProductDetailService pds = new ProductDetailService();
		product_lines = pds.ProductDetail(product_lines, id);
		product_items = pds.ProductItemDetail(product_items, id);
		for(Iterator it = product_items.iterator(); it.hasNext(); ) {
			
			Product_item pi = (Product_item) it.next();
			
			System.out.println(pi.getId());    
		}
		return SUCCESS;
	}
	
	@Override
	public List<Product_item> getModel() {
		return product_items;
	}
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	

	public List<Product_item> getProduct_items() {
		return product_items;
	}


	public void setProduct_items(List<Product_item> product_items) {
		this.product_items = product_items;
	}
	

	
	public List<Product_line> getProduct_lines() {
		return product_lines;
	}


	public void setProduct_lines(List<Product_line> product_lines) {
		this.product_lines = product_lines;
	}
	

}

